package com.nuttysoft.nutand.views;

import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.Button;

/**
 * Created by Administrator on 2016/3/10 0010.
 */
public class RoundRectButton extends Button {
    public RoundRectButton(Context context) {
        super(context);
    }

    public RoundRectButton(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public RoundRectButton(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    public RoundRectButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint paint = new Paint();
        paint.setAntiAlias(true);                       //设置画笔为无锯齿
        paint.setColor(Color.BLACK);                    //设置画笔颜色
        canvas.drawColor(Color.WHITE);                  //白色背景
        paint.setStrokeWidth((float) 3.0);              //线宽
        paint.setStyle(Paint.Style.STROKE);                   //空心效果
        RectF reactf=new RectF();                           //RectF对象//下边
        canvas.drawRoundRect(reactf, 10, 10, paint);        //绘制圆角矩形
    }
}
